package com.yc.sole.erp.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yc.sole.common.enums.CommonState;
import com.yc.sole.framework.mybatis.entity.BaseEntity;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;

/**
 * @author yizuomin
 * @date 2023/5/7 11:05
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table(name = "erp_customer",
        indexes = {@Index(name = "idx_customer_no", columnList = "customerNo", unique = true),
                @Index(name = "idx_customer_name", columnList = "customerName", unique = true)})
@TableName("erp_customer")
public class Customer extends BaseEntity {

    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 客户编号
     */
    @Column(columnDefinition = "VARCHAR(32) NOT NULL COMMENT '客户编号'", unique = true)
    private String customerNo;
    /**
     * 客户名称
     */
    @Column(columnDefinition = "VARCHAR(50) NOT NULL COMMENT '客户名称'")
    private String customerName;
    /**
     * 首字母
     */
    @Column(columnDefinition = "VARCHAR(1) NOT NULL COMMENT '名称拼音首字母'")
    private String firstLetter;
    /**
     * 联系人名称
     */
    @Column(columnDefinition = "VARCHAR(50) COMMENT '联系人名称'")
    private String contacts;
    /**
     * 手机号
     */
    @Column(columnDefinition = "VARCHAR(20) COMMENT '手机号'")
    private String phoneNum;
    /**
     * 邮箱
     */
    @Column(columnDefinition = "VARCHAR(50) COMMENT '邮箱'")
    private String email;
    /**
     * 传真
     */
    @Column(columnDefinition = "VARCHAR(50) COMMENT '传真'")
    private String fax;
    /**
     * 地址
     */
    @Column(columnDefinition = "VARCHAR(255) COMMENT '地址'")
    private String address;
    /**
     * 应收款
     */
    @Column(columnDefinition = "DECIMAL(18,2) DEFAULT 0 COMMENT '应收款'")
    private BigDecimal receivables;
    /**
     * 已收款
     */
    @Column(columnDefinition = "DECIMAL(18,2) DEFAULT 0 COMMENT '已收款'")
    private BigDecimal receivedPayment;
    /**
     * 状态
     */
    @Column(columnDefinition = "VARCHAR(1) NOT NULL COMMENT '状态'")
    private CommonState state;
    /**
     * 备注
     */
    @Column(columnDefinition = "VARCHAR(255) COMMENT '备注'")
    private String remark;
    /**
     * 是否删除
     */
    @TableLogic
    @Column(columnDefinition = "INT NOT NULL DEFAULT 0 COMMENT '是否已删除'")
    private Integer deleted;
}
